input = [1,8,6,2,5,4,8,3,7]
'''
20%
area = 0
        for i in range(len(data)):
            for j in  range(i, len(data)):
                area = max( area, min(data[i],data[j])*(j-i))
        return area
'''
40%
class Solution:
    def solution(self , data ):
        # write code here
        area = 0
        for i in range(len(data)):
            for j in range(i, len(data)):
                if data[j] <= data[i]:
                    area = max(area,data[j]*(j-i))
        return area
    print(Solution().solution(input))